package com.hyt.it.ogt.controller.ykcj.grade;


import com.hyt.it.ogt.common.config.ApiVersionConstant;
import com.hyt.it.ogt.controller.base.BaseController;
import com.hyt.it.ogt.ykcj.common.constant.HttpStatus;
import com.hyt.it.ogt.ykcj.common.core.domain.AjaxResult;
import com.hyt.it.ogt.ykcj.domain.vo.QueryExamExamineeDetailVo;
import com.hyt.it.ogt.ykcj.service.grade.IScoreQueryService;
import com.hyt.swagger.ApiVersion;
import groovy.util.logging.Slf4j;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiSort;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;


/**
 * 成绩查询Controller
 *
 * @author liying
 * @date 2021-11-19
 */
@Api(tags = "grade.12.成绩查询")
@ApiSort(value = 212)
@RestController
@RequestMapping("/score/query")
@Slf4j
public class ScoreQueryController extends BaseController {


    @Autowired
    private IScoreQueryService scoreQueryService;


    /**
     * 成绩结果查询认证
     *
     * @param examId
     * @return
     */
    @ApiOperation("成绩结果查询认证")
    @GetMapping("/verification/information")
    public AjaxResult verificationInformation(@RequestParam("examId") String examId,
                                              @RequestParam("examineeName") String examineeName,
                                              @RequestParam("admissionnNo") String admissionnNo) {
        Map<Integer, String> ret = scoreQueryService.verificationInformation(examId, examineeName, admissionnNo);
        for (Map.Entry<Integer, String> map : ret.entrySet()) {
            if (HttpStatus.SUCCESS == map.getKey().intValue()) {
                return AjaxResult.success("成功", map.getValue());
            } else {
                return new AjaxResult(map.getKey(), map.getValue());
            }

        }
        return AjaxResult.success();
    }


    /**
     * 成绩结果信息
     *
     * @param examineeId
     * @return
     */
    @ApiOperation(value = "成绩结果信息", response = QueryExamExamineeDetailVo.class)
    @ApiVersion(group = ApiVersionConstant.V2_4_2)
    @GetMapping("/queryExamExamineeResultDetail")
    public AjaxResult queryExamExamineeResultDetail(@ApiParam("考试ID") @RequestParam("examId") String examId,
                                                    @ApiParam("考生ID") @RequestParam("examineeId") String examineeId) {
        return AjaxResult.success(scoreQueryService.queryExamExamineeResultDetail(examineeId, examId));
    }

    @ApiOperation(value = "证书批量下载")
    @ApiVersion(group = ApiVersionConstant.V2_4_9)
    @GetMapping("/batchExportCertificateZip")
    public AjaxResult batchExportCertificateZip(@ApiParam("考试ID") @RequestParam("examId") String examId,
                                                @ApiParam("考生ID") @RequestParam("examineeId") String examineeId) {
        return AjaxResult.success(scoreQueryService.batchExportCertificateZip(examineeId, examId));
    }
}
